package zuoye2;

import java.util.Scanner;

public class StringDemo2 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入一个字符串：");
        String str=sc.next();
        System.out.print("请输入要查找的字符：");
        String want=sc.next();
        String[] strs=new String[str.length()];
        int count=0;
        for (int i = 0; i < strs.length; i++) {
            strs[i]=str.substring(i,i+1);
            if(strs[i].equals(want)){
                count++;
            }
        }
        System.out.println("\""+str + "\"中出现了" + count + "个\""+want+"\"");
    }
}
